function appendHtml(list) {
  for (var i = 0; i < list.length; i++) {
    var parent = list[i]
    var strVar = '';
    var pId = parent.sendcarHeaderId
    if (parent.sendcarLines && parent.sendcarLines.length) {
      strVar += '<div class="weui-cells weui-cells_checkbox" id="list_"'+pId+'>';
      strVar += '<label class="weui-cell weui-check__label weui-flex weui-cell__title" for="parent_' + pId + '">';
      strVar += '<div class="weui-cells__icon"><svg onclick="toggle(event, this, ' + pId + ')" class="toggle-expand" fill="#999999" viewBox="0 0 1024 1024" version="1.1" width="24" height="24"><path d="M348.16 277.163v469.675c0 32.768 43.691 49.152 70.997 27.307l245.76-234.837c16.384-16.384 16.384-38.229 0-54.613l-245.76-234.837c-27.307-21.845-70.997-5.461-70.997 27.307z" p-id="8648"></path></svg></div>';
      strVar += '<div class="weui-flex__item title" onclick="onSelectItem('+pId+')">送车交接单号：' + parent.sendcarOrderNumber + '</div>';
      strVar += '<div>';
      strVar += '<input type="checkbox" data-addressid="'+parent.shipToAddressId+'" data-id="'+pId+'" class="weui-check" onchange="change(this,'+i+')" name="checkbox1" id="parent_' + pId + '">';
      strVar += '<i class="weui-icon-checked"></i>';
      strVar += '</div>';
      strVar += '</label>';

      strVar += '<div id="item_s' + parent.sendcarHeaderId + '" style="display:none" class="list-items">';
      for (var j = 0; j < parent.sendcarLines.length; j++) {
        var item = parent.sendcarLines[j]
        var cId = item.sencarLineId
          strVar += '<label class="weui-cell weui-check__label weui-flex" for="child_' + pId + '_' + cId + '">';
        strVar += '<div class="weui-flex__item">'+item.vinCode+'</div>';
        strVar += '<div>';
        strVar += '<input type="checkbox" onchange="changeChild(this,'+pId+')" data-id="'+item.sencarLineId+'" class="weui-check" name="checkbox1" id="child_' + pId + '_' + cId + '">';
        strVar += '<i class="weui-icon-checked"></i>';
        strVar += '</div>';
        strVar += '</label>';
      }
      strVar += '</div>';

      strVar += '</div>';

      $("#list").append(strVar)
    }
  }
  console.log(list[0].transToolCode);
    $("#transToolCode").text(list[0].transToolCode);
    $("#driverName").text(list[0].driverName);
}

function change(th, i) {
  var cb = $(th)
  $('#item_s' + cb.data('id')).find('input').prop("checked", cb.prop('checked') ? 'checked' : null)
}
function changeChild(th, pId) {
  var cb = $(th)
  var length = $('#item_s' + pId).find('input:checked').length
  $('#parent_' + pId).prop('checked', length ? 'checked' : null)
}

function toggle(event, th, pId) {
  event.preventDefault()
  event.stopPropagation()
  $('#item_s' + pId).toggle()
  $(th).parent().toggleClass('open')
}
function onSelectItem(id) {
  if (window.selectItem) {
    selectItem(id)
  }
}
function getCheckedList() {
  var arr = []
  $('[id^="parent_"]:checked').each(function(index, item){
    var pId = $(item).data('id')
    var items = $('#item_s' + pId).find('input:checked')
    var sendcarLineIds = []
    if (items.length) {
      items.each(function(index, item2){
        var id = $(item2).data('id')
        sendcarLineIds.push(id)
      })
    }
    arr.push({
      sendcarHeaderId: pId,
      shipToAddressId: $(item).data('addressid'),
      sendcarLineIds: sendcarLineIds
    })
  })
  return arr
}